<template>
  <div class="team">
    <div>
      <a-table :columns="columns" :data-source="this.teamInfo" @change="onChange">
        <div
          class="td_name"
          slot="name"
          slot-scope="text,record"
          @click="team_info(record)"
        >{{ text }}</div>
        <div
          class="td_name"
          slot="leader"
          slot-scope="text,record"
          @click="peopleDetail(record)"
        >{{ text }}</div>
      </a-table>
    </div>
  </div>
</template>

<script>
export default {
  props: ['teamInfo'],
  data() {
    return {
      columns: [
        {
          title: '班组名称',
          dataIndex: 'name',
          key: 'name',
          scopedSlots: { customRender: 'name' },
          align: 'center'
        },
        {
          title: '班组长',
          dataIndex: 'leader',
          align: 'center',
          key: 'leader',
          scopedSlots: { customRender: 'leader' },
          align: 'center'
        },
        {
          title: '联系电话',
          dataIndex: 'cellphone',
          align: 'center'
        },
        {
          title: '在场人数',
          dataIndex: 'personTotal',
          align: 'center'
        }
      ],
      data: [
        {
          key: '1',
          name: '路基施工一队',
          leader: '李志新',
          tell: '19166120325'
        },
        {
          key: '2',
          name: '路基施工二队',
          leader: '王存义',
          tell: '16609822487'
        }
      ]
    }
  },
  methods: {
    onChange(pagination, filters, sorter) {
      console.log('params', pagination, filters, sorter)
    },
    team_info(text) {
      // console.log(text);
      sessionStorage.setItem('teamId', text.id)
      sessionStorage.setItem('teamName', text.name)
      let flag = sessionStorage.getItem('backstage')
      // sessionStorage.setItem('gatewayId', this.orgId)

      // sessionStorage.setItem('projectId', this.userInfo.projectId)

      if (flag == 'true') {
        this.$router.push({ path: '/teamGroupBack' })
      } else {
        this.$router.push({ path: '/teamGroup', query: { id: text.id } })
      }
    },
    peopleDetail(record) {
      //  sessionStorage.getItem('orgPersonId')
      sessionStorage.setItem('teamName', record.name)
      sessionStorage.setItem('teamId', record.id)
      sessionStorage.setItem('orgPersonId', record.leaderPersonId)

      let flag = sessionStorage.getItem('backstage')
      if (flag == 'true') {
        const { href } = this.$router.resolve({
          path: `/personnelInformationLabor/${record.leaderPersonId}`,
          query: { id: record.leaderPersonId }
        })

        window.open(href, '_blank')
      } else {
        this.$router.push({ path: '/personnelInformation' })
      }
    }
  }
}
</script>

<style scoped>
::v-deep .ant-table-pagination.ant-pagination {
  display: none;
}
.td_name {
  color: #1890ff;
  cursor: pointer;
}
</style>
